package zhongbo.java.air.monitor.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import zhongbo.java.air.monitor.config.RedisListenerConfig;

/**
 * 向频道log_chanel 发布广播消息
 */
@Component
@Slf4j
public class RedisPathChanelPublisher {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    /**
     * 广播消息到 live_flight_path 频道
     *
     * @param message 消息文本
     */
    public void sendMessage(String message) {
        log.info("发送消息到 live_flight_path: {}", message);
        redisTemplate.convertAndSend(RedisListenerConfig.CHANEL, message);
    }

}
